package com.atwbj.langchain4jbeta3learndemo.controller;

/**
 * @description:
 * @author: wbj
 * @create: 2025-07-21 10:20
 **/

import com.atwbj.langchain4jbeta3learndemo.aiservice.Assistant;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.response.ChatResponse;
import dev.langchain4j.model.output.TokenUsage;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/highApiTest")
public class HighApiTestController {

   //只需在需要的地方注入/自动装配 Assistant 即可，然后调用里面的方法完成业务。让我们更专注于业务逻辑.
   @Autowired
   private Assistant assistant;

   //http://localhost:8002/highApiTest/testMyAssistant
   @GetMapping(value = "/testMyAssistant")
   public String testMyAssistant(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt) {
      String result = assistant.chat(prompt);
      System.out.println("通过langchain4j的AiService接口调用模型返回结果：\n" + result);
      return result;
   }
}
